def initlog(name,grade):
    import logging

    logger=logging.getLogger(name)
    console=logging.StreamHandler()
    formatter = logging.Formatter('%(asctime)s %(levelname)s    %(message)s')
    console.setFormatter(formatter)
    logger.addHandler(console)
    if grade==1:
        logger.setLevel(logging.DEBUG)
    elif grade==2:
        logger.setLevel(logging.INFO)
    elif grade==3:
        logger.setLevel(logging.WARNING)
    elif grade==4:
        logger.setLevel(logging.ERROR)
    else:
        logger.setLevel(logging.CRITICAL)
    return logger
